package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TFlow;
import com.ruoyi.system.service.ITFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货物动态Controller
 * 
 * @author 张倍
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/flow")
public class TFlowController extends BaseController
{
    @Autowired
    private ITFlowService tFlowService;

    /**
     * 查询货物动态列表
     */
    @PreAuthorize("@ss.hasPermi('system:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFlow tFlow)
    {
        startPage();
        List<TFlow> list = tFlowService.selectTFlowList(tFlow);
        return getDataTable(list);
    }

    /**
     * 导出货物动态列表
     */
    @PreAuthorize("@ss.hasPermi('system:flow:export')")
    @Log(title = "货物动态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TFlow tFlow)
    {
        List<TFlow> list = tFlowService.selectTFlowList(tFlow);
        ExcelUtil<TFlow> util = new ExcelUtil<TFlow>(TFlow.class);
        util.exportExcel(response, list, "货物动态数据");
    }

    /**
     * 获取货物动态详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:flow:query')")
    @GetMapping(value = "/{item3Id}")
    public AjaxResult getInfo(@PathVariable("item3Id") Integer item3Id)
    {
        return success(tFlowService.selectTFlowByItem3Id(item3Id));
    }

    /**
     * 新增货物动态
     */
    @PreAuthorize("@ss.hasPermi('system:flow:add')")
    @Log(title = "货物动态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFlow tFlow)
    {
        return toAjax(tFlowService.insertTFlow(tFlow));
    }

    /**
     * 修改货物动态
     */
    @PreAuthorize("@ss.hasPermi('system:flow:edit')")
    @Log(title = "货物动态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFlow tFlow)
    {
        return toAjax(tFlowService.updateTFlow(tFlow));
    }

    /**
     * 删除货物动态
     */
    @PreAuthorize("@ss.hasPermi('system:flow:remove')")
    @Log(title = "货物动态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{item3Ids}")
    public AjaxResult remove(@PathVariable Integer[] item3Ids)
    {
        return toAjax(tFlowService.deleteTFlowByItem3Ids(item3Ids));
    }
}
